package com.bangyu.monitor.core.common.constant;

import com.google.common.collect.Maps;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;

import java.util.Map;
import java.util.Objects;

/**
 * @Auther: zhangxue
 * @Date: 19/4/6 12:47
 * @Description:
 */
public class ConstantEnum {

    public enum OrgEnum{

        ORG_1("1","组织1"),
        ORG_2("2","组织2")

        ;
        private String key;
        private String value;

        OrgEnum(String key, String value) {
            this.key = key;
            this.value = value;
        }

        public static Map toMap(){
            Map map = Maps.newHashMap();
            for(OrgEnum orgEnum:OrgEnum.values()){
                String key = orgEnum.key;
                String value = orgEnum.value;
                map.put(key,value);
            }
            return map;
        }

        public static String getName(String key){
            if(StringUtils.isBlank(key)){
                return null;
            }
            for(OrgEnum orgEnum:OrgEnum.values()){
                if(Objects.equals(key,orgEnum.key)){
                    return orgEnum.value;
                }
            }
            return null;
        }
    }

    public enum PositionEnum{

        POSITION_1("1","职位1")
            ;
        private String key;
        private String value;

        PositionEnum(String key) {
            this.key = key;
        }

        PositionEnum(String key, String value) {
            this.key = key;
            this.value = value;
        }

        public static Map toMap(){
            Map map = Maps.newHashMap();
            for(PositionEnum orgEnum:PositionEnum.values()){
                String key = orgEnum.key;
                String value = orgEnum.value;
                map.put(key,value);
            }
            return map;
        }

        public static String getName(String key){
            if(StringUtils.isBlank(key)){
                return null;
            }
            for(PositionEnum positionEnum:PositionEnum.values()){
                if(Objects.equals(positionEnum.key,key)){
                    return positionEnum.value;
                }
            }
            return null;
        }
    }

    public enum Role{
        ADMIN(1l,"超级管理员"),
        MANAGER(1105780112925159426l,"桥梁负责人"),
        TOURIST(1113377907836272641l,"游客")
        ;

        Role(Long roleId, String roleName) {
            this.roleId = roleId;
            this.roleName = roleName;
        }

        private Long roleId;
        private String roleName;

        public Long getRoleId() {
            return roleId;
        }

        public void setRoleId(Long roleId) {
            this.roleId = roleId;
        }

        public String getRoleName() {
            return roleName;
        }

        public void setRoleName(String roleName) {
            this.roleName = roleName;
        }
    }

    public enum MaintainType{
        QMWX("1","桥面维修"),
        ZZGH("2","支座更换"),
        LTJG("3","梁体加固"),
        XBJGJG("4","下部结构加固"),
        DJZJC("5","动静载检测");

        private String key;
        private String value;

        MaintainType(String key, String value) {
            this.key = key;
            this.value = value;
        }

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public static String getValByKey(String key){
            for(MaintainType type:MaintainType.values()){
                if(Objects.equals(type.key,key)){
                    return type.value;
                }
            }
            return null;
        }
    }

    public  enum Sensortype
    {
        SENSOR_ERR(0),
        AIR_TEMP(1),
        AIR_HUMI(2),
        ILLUMINATION(3),
        SOIL_TEMP(4),
        SOIL_HUMI(5),
        CO2(0X14),
        INSIDE_TEMP(0X15),
        BAT_VOLTAGE(0X16),
        SOIL_PH(0X08),
        WATER_TEMP(0X1A),
        OXYGEN(23),
        LEVEL(24),
        TTT(25)
        ;
        private int value;

        public int getValue() {
            return value;
        }

        Sensortype(int value) {
            this.value = value;
        }
    }
//恢复类型，1:6秒内恢复，2:6-60秒内恢复，3:1分钟-12小时内恢复,4:大于12小时恢复
    public enum RecoverType{
        NO_RECOVER(0),//尚未恢复
        INNER_XIX_SECOND(1),
        SIX_SIXTY_SECOND(2),
        SIXTY_SECOND_TWELVE_HOUR(3),
        MORE_THAN_TWELVE_HOUR(4)
        ;

        private Integer type;

        public Integer getType() {
            return type;
        }

        RecoverType(Integer type) {
        this.type = type;
    }
    }

    //预警类别
    //风险类型 1极限预警 2突发荷载预警3 疲劳预警
    public enum RiskType{

        RISK_TYPE_NDJX(1,"挠度极限预警"),
        RISK_TYPE_TFHZ(2,"突发荷载预警"),
        RISK_TYPE_PL(3,"疲劳预警")
        ;

        RiskType(Integer riskCode, String riskName) {
            this.riskCode = riskCode;
            this.riskName = riskName;
        }

        private Integer riskCode;
        private String riskName;

        public Integer getRiskCode() {
            return riskCode;
        }

        public String getRiskName() {
            return riskName;
        }


        public static String getName(Integer riskCode){
            for(RiskType type:RiskType.values()){
                if(type.getRiskCode()==riskCode){
                    return type.getRiskName();
                }
            }
            return null;
        }
    }



    //风险等级
    public enum RiskLevel{
        RISK_LEVEL_WARN(1,"预警"),
        RISK_LEVEL_ALARM(2,"报警");

        private Integer key;
        private String value;

        RiskLevel(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        public Integer getKey() {
            return key;
        }

        public String getValue() {
            return value;
        }

        public static String getValByKey(Integer key){
            for(RiskLevel type:RiskLevel.values()){
                if(Objects.equals(type.key,key)){
                    return type.value;
                }
            }
            return null;
        }
    }

    public enum BridgeProperty{

        //1箱梁 2空心板 3T梁 4钢架梁
        XIANGLIANG(1,"挠度极限预警"),
        KONGXINBAN(2,"突发荷载预警"),
        T_LIANG(3,"疲劳预警"),
        GANGJIALIANG(4,"疲劳预警")
        ;

        BridgeProperty(Integer key, String name) {
            this.key = key;
            this.name = name;
        }

        private Integer key;
        private String name;

        public Integer getKey() {
            return key;
        }

        public String getName() {
            return name;
        }

        public static String getName(Integer code){
            for(BridgeProperty type:BridgeProperty.values()){
                if(type.getKey()==code){
                    return type.getName();
                }
            }
            return null;
        }
    }



}
